<%--
  Created by IntelliJ IDEA.
  User: zjd
  Date: 2020/8/25
  Time: 17:56
  To change this template use File | Settings | File Templates.
--%>
<%--
  Created by IntelliJ IDEA.
  User: zjd
  Date: 2020/8/21
  Time: 11:33
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <title>场次列表</title>
    <meta charset="UTF-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/back-style/css/bootstrap.min.css"/>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/back-style/css/bootstrap-responsive.min.css"/>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/back-style/css/colorpicker.css"/>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/back-style/css/datepicker.css"/>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/back-style/css/uniform.css"/>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/back-style/css/select2.css"/>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/back-style/css/matrix-style.css"/>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/back-style/css/matrix-media.css"/>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/back-style/css/bootstrap-wysihtml5.css"/>
    <link href="${pageContext.request.contextPath}/back-style/font-awesome/css/font-awesome.css" rel="stylesheet"/>
    <link href='http://fonts.googleapis.com/css?family=Open+Sans:400,700,800' rel='stylesheet' type='text/css'>
    <link href="${pageContext.request.contextPath}/back-style/css/dashboard.css">
</head>
<body>

<!--Header-part-->
<div id="header">
    <h1><a href="dashboard.html">MatAdmin</a></h1>
</div>
<!--close-Header-part-->
<!--top-Header-menu-->
<div id="user-nav" class="navbar navbar-inverse">

</div>

<!--start-top-serch-->
<!--close-top-serch-->

<!--sidebar-menu-->

<div id="sidebar"><a href="#" class="visible-phone"><i class="icon icon-th"></i>Tables</a>
    <ul>
        <li><a href="${pageContext.request.contextPath}/admin/toUsersList"><i class="icon icon-home"></i>
            <span>首页</span></a></li>
        <li><a href="${pageContext.request.contextPath}/admin/toAddMovies"><i class="icon icon-signal"></i>
            <span>添加电影</span></a></li>
        <li><a href="${pageContext.request.contextPath}/admin/toMoviesDetail"><i class="icon icon-inbox"></i>
            <span>电影详情</span></a></li>
        <li><a href="${pageContext.request.contextPath}/admin/toCharts"><i class="icon icon-th"></i> <span>图表</span></a>
        </li>
        <li><a href="${pageContext.request.contextPath}/admin/toAdminList"><i class="icon icon-fullscreen"></i> <span>管理列表</span></a>
        </li>
        <li><a href="${pageContext.request.contextPath}/admin/toAddShowing"><i class="icon icon-fullscreen"></i> <span>添加场次</span></a>
        </li>
        <li class="active"><a href="${pageContext.request.contextPath}/admin/toShowingList"><i
                class="icon icon-fullscreen"></i> <span>全部场次</span></a></li>
        <li><a href="${pageContext.request.contextPath}/admin/toAddCinemas"><i class="icon icon-fullscreen"></i> <span>添加放映厅</span></a>
        </li>
        <li><a href="${pageContext.request.contextPath}/admin/toCinemasList"><i class="icon icon-fullscreen"></i> <span>全部放映厅</span></a>
        </li>
        <li><a href="${pageContext.request.contextPath}/admin/toAddType"><i class="icon icon-fullscreen"></i> <span>添加展厅类型</span></a>
        </li>
        <li><a href="${pageContext.request.contextPath}/admin/toAddCate"><i class="icon icon-fullscreen"></i> <span>电影类型添加</span></a>
        </li>

    </ul>
</div>
<div id="content">
    <div class="container-fluid">
        <hr>
        <div class="row-fluid">
            <div class="span12">
                <div class="widget-box">
                    <div class="widget-title"><span class="icon"> <i class="icon-th"></i> </span>
                        <h2>场次列表</h2>
                    </div>
                    <div class="widget-content nopadding">
                        <table class="table table-bordered table-striped" id="showing-list">
                            <thead>
                            <tr>
                                <th>场次编号</th>
                                <th>场次时间</th>
                                <th>剩余座位</th>
                                <th>展厅名称</th>
                                <th>电影名称</th>
                            </tr>
                            </thead>
                            <tbody>
                            <tr>
                                <td>Trident</td>
                                <td>Internet
                                    Explorer 4.0
                                </td>
                                <td>Win 95+</td>
                                <td class="center"> 4</td>
                                <td class="center">X</td>
                            </tr>
                            </tbody>
                        </table>

                    </div>
                    <div class="container-fluid text-center">
                        <ul class="pager" id="footlist">
                        </ul>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<!--Footer-part-->
<div class="row-fluid">
    <div id="footer" class="span12">Copyright &copy; 2018.Company name All rights reserved.<a target="_blank"
                                                                                              href="http://sc.chinaz.com/moban/">&#x7F51;&#x9875;&#x6A21;&#x677F;</a>
    </div>
</div>
<!--end-Footer-part-->
<script src="${pageContext.request.contextPath}/back-style/js/jquery.min.js"></script>
<script src="${pageContext.request.contextPath}/back-style/js/jquery.ui.custom.js"></script>
<script src="${pageContext.request.contextPath}/back-style/js/bootstrap.min.js"></script>
<script src="${pageContext.request.contextPath}/back-style/js/jquery.uniform.js"></script>
<script src="${pageContext.request.contextPath}/back-style/js/select2.min.js"></script>
<script src="${pageContext.request.contextPath}/back-style/js/jquery.dataTables.min.js"></script>
<%--<script src="${pageContext.request.contextPath}/back-style/js/matrix.js"></script>--%>
<script src="${pageContext.request.contextPath}/back-style/js/matrix.tables.js"></script>
</body>
<script>
    $(function () {
        lod();
    })
</script>
<script>
    function lod() {
        $.post("${pageContext.request.contextPath}/showings/queryAll", {},
            function (data) {
                loadata(data)
            }, "json")
    }

    function loadata(data) {
        var content = "<thead>\n" +
            "                            <tr>\n" +
            "                                <th>场次编号</th>\n" +
            "                                <th>场次时间</th>\n" +
            "                                <th>剩余座位</th>\n" +
            "                                <th>展厅名称</th>\n" +
            "                                <th>电影名称</th>\n" +
            "                                <th>操作</th>\n" +
            "                            </tr>\n" +
            "                            </thead>\n" +
            "                            <tbody>"
        console.log(data)
        $.each(data.list, function (index, obj) {
            content += "<tr>\n" +
                "                                <td>" + obj.showing_no + "</td>\n" +
                "                                <td>" + obj.showing_date + "</td>\n" +
                "                                <td>" + obj.showing_seat + "</td>\n" +
                "                                <td class=\"center\">" + obj.cinemas.cinema_name + "</td>\n" +
                "                                <td class=\"center\">" + obj.movies.movieName + "</td>\n" +
                "                                <td class=\"center\"><a class='button' href='javascript:del(" + obj.showing_no + "," + data.pageNum + ")'>删除</a></td>\n" +
                "                            </tr>"
        })
        content += "</tbody>"
        $("#showing-list").empty()
        $("#showing-list").append(content)

        $("#footlist").empty()
        if (data.isFirstPage) {
            $("#footlist")
                .append(
                    "<li class=\"page-item disabled\"><a class=\"page-link\" href=\"#\">首页</a></li>")
        } else {
            $("#footlist")
                .append(
                    "<li class=\"page-item\"><a class=\"page-link\" onclick=\"frpage()\">首页</a></li>")
        }

        if (data.isFirstPage) {
            $("#footlist")
                .append(
                    "<li class=\"page-item disabled\"><a class=\"page-link\" href=\"#\">上一页</a></li>")
        } else {
            $("#footlist").append(
                "<li class=\"page-item\"><a class=\"page-link\" onclick=\"topage("
                + (data.pageNum - 1) + ")\">上一页</a></li>")
        }
        for (i = 1; i <= data.pages; i++) {
            if (i == data.pageNum) {
                $("#footlist").append(
                    "<li class=\"page-item active disabled\"><a class=\"page-link\">"
                    + i + "</a></li>")
            } else {
                $("#footlist").append(
                    "<li class=\"page-item\"><a class=\"page-link\" onclick=\"topage("
                    + i + ")\">" + i + "</a></li>")
            }
        }
        if (data.pageNum == data.pages) {
            $("#footlist")
                .append(
                    "<li class=\"page-item disabled\"><a class=\"page-link\" href=\"#\">下一页</a></li>")
        } else {
            $("#footlist").append(
                "<li class=\"page-item\"><a class=\"page-link\" onclick=\"topage("
                + (data.pageNum + 1) + ")\">下一页</a></li>")
        }
        if (data.pageNum == data.pages) {
            $("#footlist")
                .append(
                    "<li class=\"page-item disabled\"><a class=\"page-link\">末页</a></li>")
        } else {
            $("#footlist").append(
                "<li class=\"page-item\"><a class=\"page-link\" onclick=\"enpage("
                + data.totalPage + ")\">末页</a></li>")
        }
    }
</script>
<script>
    function del(showing_no, i) {
        var b = confirm("确认删除吗？");
        if (b) {
            $.post("${pageContext.request.contextPath}/showings/delShowing",
                {showing_no: showing_no},
                function (data) {
                    if (data) {
                        topage(i)
                    } else {
                        alert("删除失败")
                    }
                })
        }
    }
    function topage(i) {
        $.post("${pageContext.request.contextPath }/showings/queryAll", {
            pageNum: i
        }, function (result) {
            loadata(result)
        }, "json")
    }

    //首页
    function frpage() {
        topage(1)
    }

    //尾页
    function enpage(enpage) {
        topage(enpage)
    }

    //跳转
    function tonumpage(totl, page) {
        num = $("#tonum").val();
        if (num > 0 && num <= totl) {
            topage(num)
        } else {
            $("#tonum").val(page);
        }
    }
</script>
</html>

